using System;
using System.Collections.Generic;

namespace MessagingWPF.Infrastructure
{
	/// <summary>
	/// Creates <see cref="Subscription"/> instances for specified subscriber instances and types.
	/// </summary>
	public interface ISubscriptionAssembler
	{
		/// <summary>
		/// Infers all message subscriptions from the specified type.
		/// </summary>
		/// <param name="subscriberType">The type of the subscriber.</param>
		/// <returns>
		/// A collection of <see cref="Subscription"/>.
		/// </returns>
		/// <exception cref="ArgumentNullException">
		/// Thrown when <paramref name="subscriberType"/> is <c>null</c>.
		/// </exception>
		/// <remarks>
		/// Returns an empty collection if no subscriptions inferred.
		/// Inferred subscriptions are cached.
		/// </remarks>
		IEnumerable<Subscription> GetAllSubscriptions(Type subscriberType);

		/// <summary>
		/// Infers all message subscriptions from the specified instance.
		/// </summary>
		/// <param name="subscriber">The subscriber.</param>
		/// <returns>
		/// A collection of <see cref="Subscription"/>.
		/// </returns>
		/// <exception cref="ArgumentNullException">
		/// Thrown when <paramref name="subscriber"/> is <c>null</c>.
		/// </exception>
		/// <remarks>
		/// Returns an empty collection if no subscriptions inferred.
		/// Inferred subscriptions are cached.
		/// </remarks>
		IEnumerable<Subscription> GetAllSubscriptions(object subscriber);

		/// <summary>
		/// Creates a single <see cref="Subscription"/> for the specified subscriber.
		/// </summary>
		/// <typeparam name="TMessage">The type of the message.</typeparam>
		/// <param name="subscriber">The subscriber instance.</param>
		/// <returns>A <see cref="Subscription"/> instance.</returns>
		/// <exception cref="ArgumentNullException">
		/// Thrown when <paramref name="subscriber"/> is <c>null</c>.
		/// </exception>
		Subscription GetSingleSubscription<TMessage>(ISubscriber<TMessage> subscriber);
	}
}